package _08Comparator比较器排序.练习;


import java.util.Comparator;
import java.util.TreeSet;

public class Test {
    public static void main(String[] args) {
        TreeSet<Student> students = new TreeSet<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
               double result = o2.getScore()-o1.getScore();
                if (result<0){
                    return -1;
                }else if (result>0){
                    return 1;
                }else {
                    return 0;
                }
            }
        });

        students.add(new Student("aaa",80.5));
        students.add(new Student("bbb",90.2));
        students.add(new Student("ccc",93.7));

        System.out.println(students);


    }
}
